﻿using MediatR;
using W.Purchase.API.Application.Command.ClientCommand;
using W.Purchase.Domain;
using W.Purchase.Repository.Interface;

namespace W.Purchase.API.Application.CommandHandler.ClientCommandHandler
{
    public class ContactUpdateCommandHandler : IRequestHandler<ContactUpdateCommand, int>
    {
        private readonly IContactRepository repository;
        public ContactUpdateCommandHandler(IContactRepository repository)
        {
            this.repository = repository;
        }
        public async Task<int> Handle(ContactUpdateCommand request, CancellationToken cancellationToken)
        {
            return await repository.Update(new Domain.Contact()
            {
               ContactId=request.ContactId,
               ContactName=request.ContactName,
               ContactAddress=request.ContactAddress,
               ContactPhone=request.ContactPhone,
               office_id = request.office_id,
               user_id = request.user_id,
               CreateName = request.CreateName,
               CreateTime = request.CreateTime,
               UpdateName = request.UpdateName,
               UpdateTime = request.UpdateTime,
               DeleteName = request.DeleteName,
               DeleteTime = request.DeleteTime,
               IsDelete = request.IsDelete,

            });
        }
    }
}
